** This file produces Figures 2.1 and 2.3

* Open dataset generated from Catalist of distribution of ideology among all voters 
use allvoters, clear

* Merge datasets generated from Catalist of distribution of ideology among federal donors and then state donors 
sort ideo2
merge ideo2 using donors
drop _m
sort ideo2
merge ideo2 using statedonors

* Recode the ideology measure so that it ranges from liberal to conservative
replace ideo2=(ideo2-21)*-1

* Generate histograms for Figure 2.2
twoway bar active ideo2 if ideo2>0, scheme(s1mono) aspect(1) xlabel(1 "Very Liberal" 10 "Moderate" 20 "Very Conservative         ") xtitle(" ") ylabel(5000000 "5 million" 10000000 "10 million" 15000000 "15 million" 20000000 "20 million", angle(0)) ytitle(" ") title("Registered Voters")  saving(voters, replace)
graph export fig_2_1a.eps, replace
twoway bar donors ideo2 if ideo2>0, scheme(s1mono) aspect(1) xlabel(1 "Very Liberal" 10 "Moderate" 20 "Very Conservative    ") xtitle(" ") ylabel(20000 "    20,000" 40000 "    40,000" 60000 "    60,000" 80000 "    80,000" , angle(0)) ytitle(" ") title("Federal Donors")  saving(donors, replace)
graph export fig_2_1b.eps, replace
twoway bar statedonors ideo2 if ideo2>0, scheme(s1mono) aspect(1) xlabel(1 "Very Liberal" 10 "Moderate" 20 "Very Conservative    ") xtitle(" ") ylabel( 20000 "    20,000" 40000 "    40,000" 60000 "    60,000" 80000 "    80,000" 100000 "    100,000", angle(0)) ytitle(" ") title("State Donors")  saving(statedonors, replace)
graph export fig_2_1c.eps, replace

graph combine voters.gph statedonors.gph donors.gph, graphr(c(white)) r(1) altshrink
graph export fig_2_1.eps, replace

* Open dataset generated from Catalist showing distribution of ideology among 
*individuals who donate to state parties and individuals who donate to candidates
use state_party_cand, clear

* Recode ideology scale to range from liberal to conservative
sort ideology
gen ideo2=_n
drop if ideo2==21
replace ideo2=(ideo2-21)*-1

* Rename misspelled variable
ren canddiates candidates

* Create histograms for top row of Figure 2.3
twoway bar candidates ideo2 if ideo2>0, scheme(s1mono) aspect(1) xlabel(1 "Very Liberal" 10 "Moderate" 20 "Very Cons.        ") xtitle(" ") ylabel(20000 "    20,000" 40000 "    40,000" 60000 "    60,000" 80000 "    80,000" 100000 "   100,000", angle(0)) ytitle(" ") title("Donors to Candidates")  saving(candidates, replace)
twoway bar parties ideo2 if ideo2>0, scheme(s1mono) aspect(1) xlabel(1 "Very Liberal" 10 "Moderate" 20 "Very Cons.        ") xtitle(" ") ylabel(2000 "    2,000" 4000 "    4,000" 6000 "    6,000" 8000 "    8,000" 10000 "    10,000", angle(0)) ytitle(" ") title("Donors to Parties")  saving(parties, replace)
graph combine candidates.gph parties.gph , graphr(c(white)) r(1)
graph export fig_2_3a.eps, replace

* Open dataset generated from Catalist showing total amount donated to candidates
* and parties in each ideological category
use candidate_party_amount, clear

* Recode ideology scale to range from liberal to conservative
sort ideology
gen ideo2=_n
drop if ideo2==21
replace ideo2=(ideo2-21)*-1

* Create histograms for bottom row of Figure 2.3
twoway bar candidate_amount ideo2 if ideo2>0, scheme(s1mono) aspect(1) xlabel(1 "Very Liberal" 10 "Moderate" 20 "Very Cons.        ") xtitle(" ") ylabel(10000000 "    $10 million" 20000000 "    $20 million" 30000000 "    $30 million", angle(0)) ytitle(" ") title("Amount to Candidates")  saving(candidates, replace)
twoway bar party_amount ideo2 if ideo2>0, scheme(s1mono) aspect(1) xlabel(1 "Very Liberal" 10 "Moderate" 20 "Very Cons.        ") xtitle(" ") ylabel(4000000 "    $4 million" 8000000 "    $8 million" 12000000 "    $12 million" , angle(0)) ytitle(" ") title("Amount to Parties")  saving(parties, replace)
graph combine candidates.gph parties.gph , graphr(c(white)) r(1)
graph export fig_2_3b.eps, replace


